﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FluentETL.Impl
{
    public class CustomSource: ISource
    {
        private IEnumerable<IRow> DataSource { get; set; }

        public CustomSource From(IEnumerable<IRow> dataSource)
        {
            this.DataSource = dataSource;
            return this;
        }

        void ISource.InTransformContext(ITransform t, Action action)
        {
            action();
        }
 
        IEnumerable<IRow> ISource.Rows
        {
            get
            {
                if (this.DataSource == null)
                    throw new InvalidOperationException("No data source set.");
                foreach (IRow r in this.DataSource)
                {
                    yield return r;
                }
            }
        }
    }
}
